home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / COMM / ANSI_133 / PINGANSI.DOC < prev    next >
Text File  |  1990-08-22  |  7KB  |  222 lines

  1. PingAnsi v1.33 (c) CopyRight 1990 P.H.Rankin Hansen.
  2. Musica v1.00 (c) CopyRight 1990 P.H.Rankin Hansen.
  3. PoorMan v1.00 (Public Domain)
  4.  
  5. The  PingAnsi  unit  provides  partial  Ansi  emulation for Turbo
  6. Pascal  versions  5.x  and  higher.  (version  4 does not support
  7. procedural types). Some routines may be handled in a non-standard
  8. way.
  9.  
  10. The Musica unit implements the Play statement known from Basic.
  11.  
  12. The  PoorMan unit  implements replacements  for the  few routines
  13. from Turbo Power Professional  needed to compile PingAnsi without
  14. access to the  Turbo Power units. It is  recommended that You use
  15. the original Turbo Power toolbox partly due to the limitations in
  16. the  standard Crt  unit, partly  because the  Turbo Power  units,
  17. IMHO, are really good.
  18.  
  19. Released in Denmark on August 23rd 1990.
  20.  
  21. By  using this  material You  assume FULL  responsibility for ANY
  22. consequences  -  direct  or  indirect  -  thereof.
  23.  
  24. Any dispute  regarding this material shall  be setteled by Danish
  25. law and in a Danish Court.
  26.  
  27. (Sigh!)
  28.  
  29. This source may  NOT be used by Lawyers,  Politicians or, persons
  30. engaged in  any other form  of terrorism. Otherwise  the usage is
  31. free.
  32.  
  33. This source may be freely distributed as long as no fee is charged.
  34.  
  35.  
  36.  
  37.                         Acknowlegdements:
  38.  
  39. The  text file  device driver  mechanism was  suggested by Robert
  40. Mashlan (1:147/34.33)
  41.  
  42. The so called 'Ansi'-music is due to steady prompting and lots of
  43. small hints from Dan Wulff, Dragons Lair (2:231/57.0)
  44.  
  45. The routines  in PoorMan vere modified  from routines supplied by
  46. Robert Mashlan  (1:147/34.33) and Trevor  Carlsen (3:690/644) for
  47. this purpose.
  48.  
  49. Thanks to Dan Wulff and Dale Barnes for discovering the errors.
  50.  
  51. In creating the  units I have used Turbo  Pascal 5.5 Professional
  52. (Borland),  Turbo  Analyst  5.04  and  Turbo Professional Toolbox
  53. 5.07 (Turbo Power).
  54.  
  55. The units were  written to end the steady  stream of questions in
  56. the  international  Pascal  echo  about  how  to  implement  Ansi
  57. emulation with turbo Pascal. Sofar it looks like it has increased
  58. the number.
  59.  
  60.  
  61.  
  62.                          Using the units:
  63.  
  64. (This is a preliminary document and NOT complete ! )
  65.  
  66. First  let  me  make  one  thing  prefectly  clear.  If You issue
  67. grabtimer function in  the Musica unit, the 8253  timer 0 will be
  68. re-programmed to a 1 ms period. Therefore Interrupt 8 occurs 1000
  69. times a second  instead of 18.2 times. The  original interrupt is
  70. called only once every 55  interrupts and the system is therefore
  71. operating like usual. If You  have other routines that re-program
  72. timer 0 the result will propably be less than impressing. Keep in
  73. mind that problems may also occur  if a TSR with memory-swap pops
  74. up on top  of the interrupt handler. You  can normalize the timer
  75. and release the interrupt using the procedure ReleaseTimer.
  76.  
  77. First  You have  to decide  how You  are going  to use the units.
  78. There are  four conditionals (TurboPower, Small,  BBS and, Music)
  79. that govern the function of PingAnsi.
  80.  
  81. TurboPower   governs   wether   the   TurboPower   units  or  the
  82. replacements are to be used.
  83.  
  84. The  conditional  'Small'  defines  wether  the  Text File device
  85. driver should be included. The  Device driver will  be slower for
  86. single  characters, but  presumably  faster  for strings.  If You
  87. define  'Small' the  driver part   will be  left out.  Wether You
  88. include  the  text  file  driver  will  have  NO influence on the
  89. AnsiWrite function, only on the size of the compiled unit.
  90.  
  91. The  conditional  'BBS'  defines  wether  the  hook BBSHook(Char)
  92. should be called as well as AnsiWrite during writes. Use this for
  93. echoing all Write(Ansi,......) to e.g. the ComPort or a log file.
  94.  
  95. The  conditional 'Music'  defines wether  the Ansi  parser should
  96. check for so called Ansi music. Please note that this is NOT part
  97. of the Ansi  specs., but the name sticks and  I have been _asked_
  98. to implement  it. I have  interfaced the procedure  PlayHook(St :
  99. String) wich, using the Musica unit, can be used to implement the
  100. Play  statement  known  from  Basic.  Musica  supports background
  101. buffering of music.
  102.  
  103.  
  104.  
  105.                              HOOKS:
  106.  
  107. Several hooks besides BBSHook are implemented.
  108.  
  109. ReplyHook     : Procedure(St : String);
  110.  
  111. ReplyHook  is  a  hook  for  implementing  Your own Device Status
  112. Report  procedure. It  defaults to  a procedure  that places  the
  113. response in  the keyboard buffer,  but can be  redirected to e.g.
  114. sending the report to the comport.
  115.  
  116.   KeyHook     : Procedure(St : String);
  117.  
  118. KeyHook   is  a   hook   for   implementing  Your   own  KeyBoard
  119. Re-assignment. You could  use this in a comms.  program to report
  120. attempts to re-assign Your keyboard.
  121.  
  122.   WriteHook   : Procedure(Ch : Char);
  123.  
  124. WriteHook is a Hook for handling control chars i.e. Ord(Ch) < $20
  125.  
  126.   PlayHook : Procedure(Tone, Duration : word);
  127.  
  128. This hook is for implementing 'Ansi' music.
  129.  
  130.  
  131.  
  132.                            VARIABLES:
  133.  
  134. Several variables have been interfaced:
  135.  
  136. Ansi is the name of the Text file device driver.
  137.  
  138. Wrap is  set to true  if cursor should  wrap at the  screen edge.
  139. Defaults to true.
  140.  
  141. ReportedX are ReportedY the reported  cursor location issued by a
  142. parsed  position  report.  i.e.  if  the  string  #27[#;#R is run
  143. through the parser.
  144.  
  145.  
  146.  
  147.                     PROCEDURES AND FUNCTIONS:
  148.  
  149. Procedure AnsiWrite(Ch : Char);
  150.  
  151. This is the main routine.
  152.  
  153. Function In_Ansi : Boolean;
  154.  
  155. Returns true if a ansi sequence is pending.
  156.  
  157. Procedure AssignAnsi(Var f : Text);
  158.  
  159. This is used like AssignCrt. It  resets the driver. The driver is
  160. automatically assigned  to the file  Ansi at startup,  but You're
  161. the boss...
  162.  
  163. You handle the Text file device driver like any other write:
  164.  
  165. Write(Ansi,whatever....
  166.  
  167.  
  168.  
  169.                              Musica:
  170.  
  171. This unit can be used as a  standalone unit as it does not depend
  172. on the PingAnsi unit.
  173.  
  174. Const
  175.   WaitForEmpty : boolean = True;
  176.  
  177. Governs the  behavior of the  procedure that places  the motes in
  178. the background buffer. If set to true and the PlayBuffer is full,
  179. stuff  will wait  until space  is awailable  before returning. If
  180. false and the PlayBuffer is full, stuff will discard the note and
  181. return (buffer overrun).
  182.  
  183. Procedure Play(St : String);
  184.  
  185. Implements the parsing of the play strings.
  186.  
  187. Function PlayBufferEmpty : boolean;
  188.  
  189. Returns true if the background buffer  is empty. You can use this
  190. to prevent certain  events from taking place until  the music has
  191. finished.
  192.  
  193. e.g.
  194.  
  195.                 While Not PlayBufferEmpty do {};
  196.                 Exit;
  197.  
  198. Function PlayBufferFull : boolean;
  199.  
  200. Returns true if  the background buffer is Full.  You can use this
  201. to  prevent  buffer  overrun  (if  WaitForEmpty  is  false) or to
  202. prevent  the  system  from  beeing  'locked'  (if WaitForEmpty is
  203. True).
  204.  
  205. Function GrabTimer : Boolean;
  206.  
  207. Installs the background handler and sets up ExitProc to unload it
  208. upon exit. If  it returns false the handler  was not instaled due
  209. to an incompatible timer mode.
  210.  
  211. Procedure ReleaseTimer;
  212.  
  213. Uninstalls the background handler.
  214.  
  215.  
  216.                      CONTACTING THE AUTHOR:
  217.  
  218. Please  direct  any   comments,  corrections,  modifications  via
  219. netmail to:
  220.  
  221.            Ping Hansen - FidoNet address: 2:231/62.58
  222.